package com.iphanta.community.following.web;

import com.iphanta.community.common.entity.DataResult;
import com.iphanta.community.common.utils.ResultUtils;
import com.iphanta.community.following.service.DynamicService;
import com.iphanta.community.following.service.TestDynamicService;
import com.iphanta.community.following.traffic.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 动态接口
 *
 * @author 墨声 E-mail: zehong.hongframe.huang@gmail.com
 * create time: 2/15/22 3:21 PM
 */
@RestController
@RequestMapping("community/dynamic/")
public class DynamicController {

    private static final Logger LOGGER = LoggerFactory.getLogger(DynamicController.class);

    @Autowired
    private DynamicService dynamicService;

    @Autowired
    private TestDynamicService testDynamicService;

    /**
     * 发布动态
     *
     * @param request
     * @return
     */
    @PostMapping("publishDynamic")
    public DataResult<PublishDynamicResponse> publishDynamic(@RequestBody PublishDynamicRequest request) {
        return ResultUtils.SUCCESS.result(dynamicService.publishDynamic(request));
    }


    /**
     * 个人主页动态
     *
     * @param request
     * @return
     */
    @PostMapping("homepageDynamic")
    public DataResult<HomepageDynamicResponse> homepageDynamic(@RequestBody HomepageDynamicRequest request) {
        return ResultUtils.SUCCESS.result(dynamicService.homepageDynamic(request));
    }

    /**
     * 关注页动态流
     *
     * @param request
     * @return
     */
    @PostMapping("dynamicFlow")
    public DataResult<DynamicFlowResponse> dynamicFlow(@RequestBody DynamicFlowRequest request) {
        return ResultUtils.SUCCESS.result(dynamicService.dynamicFlow(request));
    }

    /**
     * 广场页动态流
     *
     * @param request
     * @return
     */
    @PostMapping("squareFlow")
    public DataResult<DynamicFlowResponse> squareFlow(@RequestBody DynamicFlowRequest request) {
        return ResultUtils.SUCCESS.result(dynamicService.squareFlow(request));
    }

    /**
     * 标签页动态流
     *
     * @param request
     * @return
     */
    @PostMapping("tagDynamicFlow")
    public DataResult<TagDynamicResponse> tagDynamicFlow(@RequestBody TagDynamicRequest request) {
        return ResultUtils.SUCCESS.result(dynamicService.tagDynamicFlow(request));
    }

    /**
     * 发布评论
     *
     * @param request
     * @return
     */
    @PostMapping("publishComment")
    public DataResult<PublishCommentResponse> publishComment(@RequestBody PublishCommentRequest request) {
        return ResultUtils.SUCCESS.result(this.dynamicService.publishComment(request));
    }

    /**
     * 评论列表
     *
     * @param request
     * @return
     */
    @PostMapping("comments")
    public DataResult<DynamicCommentsResponse> comments(@RequestBody DynamicCommentsRequest request) {
        return ResultUtils.SUCCESS.result(this.dynamicService.comments(request));
    }

    /**
     * 点赞动态
     *
     * @param request
     * @return
     */
    @PostMapping("likeDynamic")
    public DataResult<LikeDynamicResponse> likeDynamic(@RequestBody LikeDynamicRequest request) {
        return ResultUtils.SUCCESS.result(this.dynamicService.likeDynamic(request));
    }

//    /**
//     * 点赞评论
//     *
//     * @param request
//     * @return
//     */
//    @PostMapping("likeComment")
//    public DataResult likeComment() {
//        return null;
//    }

//    /**
//     * 点评列表
//     *
//     * @param request
//     * @return
//     */
//    @PostMapping("likes")
//    public DataResult<DynamicLikeResponse> likes(@RequestBody DynamicLikeRequest request) {
//        return ResultUtils.SUCCESS.result(this.dynamicService.likes(request));
//    }

    /**
     * 撤回动态、评论、点赞
     *
     * @param request
     * @return
     */
    @PostMapping("retract")
    public DataResult<RetractionResponse> retract(@RequestBody RetractionRequest request) {
        return ResultUtils.SUCCESS.result(this.dynamicService.retract(request));
    }

//    public DataResult<>


}
